package com.OrderingSystem.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@ApiModel(value = "返回结果对象", description = "返回结果对象")
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    @ApiModelProperty(value = "状态码", required = true, example = "200")
    private String code;
    @ApiModelProperty(value = "提示信息", required = true, example = "success")
    private String msg;
    @ApiModelProperty(value = "数据", required = true)
    private Object data;

    public static Result success() {
        Result result = new Result();
        result.setCode("200");
        result.setMsg("success");
        return result;
    }

    public static Result success(Object data) {
        Result result = success();
        result.setData(data);
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setCode("500");
        result.setMsg(msg);
        return result;
    }
}
